﻿using System;
using System.Linq;
using System.Text;
using DevExpress.Xpo;
using DevExpress.ExpressApp;
using System.ComponentModel;
using DevExpress.ExpressApp.DC;
using DevExpress.Data.Filtering;
using DevExpress.Persistent.Base;
using System.Collections.Generic;
using DevExpress.ExpressApp.Model;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;

namespace aztall.Module.BusinessObjects
{
	public static class Env
	{
		public static int CurrentDomainOid;
		public static string CurrentDomainCode;
		private static DateTime _DateTime = DateTime.MinValue;

		public static DateTime GetServerDateTime(Session session)
		{
			if (Math.Abs((DateTime.Now - _DateTime).Milliseconds) > 100)
			{
				_DateTime = (DateTime)session.ExecuteScalar("select GetDate()");
			}
			return _DateTime;
		}
		public static User GetCurrentUser(Session session)
		{
			if (SecuritySystem.CurrentUserId != null)
				return session.GetObjectByKey<User>(SecuritySystem.CurrentUserId);
			else
				return null;
		}
	}
}
